import {HashRouter,Routes,Route,Navigate,BrowserRouter} from 'react-router-dom'
// 路由懒加载
import { lazy,Suspense } from 'react'

// 路由路径
let arr=[
    {
        path:'/',
        to:'/home'
    },
    {
        path:'/home',
        element:lazy(()=>import('../views/Home/index'))
    },
    {
        path:"/ee",
        element:lazy(()=>import('../views/Equipment/index'))
    },
    {
        path:"/ss",
        element:lazy(()=>import('../views/Security/index'))
    },
    {
        path:"/qq",
        element:lazy(()=>import('../views/Employment/index'))
    }
]
// 定义组件
const Router=()=>{
    return (
        <Suspense fallback={<div>加载中</div>}>
<BrowserRouter>
            <Routes>
                {
                    arr.map((item,index)=>{
                        return (
                            <Route key={index} path={item.path} element={item.element?<item.element></item.element> : <Navigate to={item.to}></Navigate>}></Route>
                        )
                    })
                }
            </Routes>
        </BrowserRouter>
        </Suspense>
        
    )
}

// 导出组件
export default Router;